//
//  ViewController.m
//  LNSlideView
//
//  Created by 申铭 on 15/11/15.
//  Copyright © 2015年 shenming. All rights reserved.
//

#import "ViewController.h"
#import "LNSlideView.h"
#import "LNTableOneController.h"
#import "LNTableTwoController.h"
#import "LNTableThreeController.h"

@interface ViewController ()<LNSlideViewDelegate>
{
    NSMutableArray *_controlArray;
    LNTableOneController *_one;
    LNTableTwoController *_two;
    LNTableThreeController *_three;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGRect screenBound = [[UIScreen mainScreen] bounds];
    screenBound.origin.y = 64;
    
    // 标题数组需要和视图数组大小保持一致
    NSMutableArray *topTitleArray = [[NSMutableArray alloc] initWithArray:@[@"视图一",@"视图二",@"视图三",@"视图四",@"视图五",@"视图六",@"视图七"]];
    
    NSMutableArray *controlArray = [NSMutableArray array];
    _one = [[LNTableOneController alloc]init];
    _two = [[LNTableTwoController alloc]init];
    _three = [[LNTableThreeController alloc]init];
    LNTableOneController *onw1 = [[LNTableOneController alloc]init];
    LNTableOneController *onw2 = [[LNTableOneController alloc]init];
    LNTableOneController *onw3 = [[LNTableOneController alloc]init];
    LNTableOneController *onw4 = [[LNTableOneController alloc]init];
    [controlArray addObject:_one];
    [controlArray addObject:_two];
    [controlArray addObject:_three];
    [controlArray addObject:onw1];
    [controlArray addObject:onw2];
    [controlArray addObject:onw3];
    [controlArray addObject:onw4];

    _controlArray = controlArray;
    
    LNSlideView *slideView = [[LNSlideView alloc]initWithFrame:screenBound controlArray:controlArray topTitleArray:topTitleArray topViewHeight:50];
    slideView.delegate = self;
//    [slideView setBtnTitleColor:[UIColor redColor]];
//    [slideView setSlideIndicatorViewColor:[UIColor greenColor]];
    [self.view addSubview:slideView];
}

#pragma mark LNSlideView的代理
- (void)lnSlideView:(LNSlideView *)lnSlideView currentPage:(int)currentPage
{
    UITableViewController *table = _controlArray[currentPage];
    if ([table isKindOfClass:[LNTableOneController class]]) {
        [_one loadData];
    } else if ([table isKindOfClass:[LNTableTwoController class]]) {
        [_two loadData];
    } else if ([table isKindOfClass:[LNTableThreeController class]]) {
        [_three loadData];
    }
}
@end
